use "*/Replication files/Panel data/panel_slim.dta" , clear
set more off



*RACIAL RESENTMENT: Conditions Make it Difficult for Blacks to Succeed
gen racial_resentment1 = M001511	
recode racial_resentment1 (1=5) (5=1) (4=2) (2=4)

*RACIAL RESENTMENT: Blacks Should Not Have Special Favors to Succeed
gen racial_resentment2 = M001508	
*recode racial_resentment2 (8=.) (9=.)

*RACIAL RESENTMENT: Blacks Must Try Harder to Succeed
gen racial_resentment3 = M001510	
*recode racial_resentment3 (8=.) (9=.)

*RACIALRESENTMENT: Blacks Gotten Less than They Deserve Over the Past Few Years
* Higher values represent more resentment; coded to range from zero to one
gen racial_resentment4 = M001509	
*recode racial_resentment4 (8=.) (9=.)
recode racial_resentment4 (1=5) (5=1) (4=2) (2=4)

alpha racial_resentment1 racial_resentment2 racial_resentment3 racial_resentment4 

foreach v of var racial_resentment1 racial_resentment2 racial_resentment3 racial_resentment4 { 
	su `v', meanonly 
	gen `v'_2 = (`v' - r(min))/(r(max) - r(min)) 
}

alpha racial_resentment1_2 racial_resentment2_2 racial_resentment3_2 racial_resentment4_2

gen racial_resentment = (racial_resentment1 + racial_resentment2 + ///
	racial_resentment3 + racial_resentment4)/4

	
revrs racial_resentment , replace

gen satis_00 = M001651
revrs satis_00 , replace
gen satis_02 = M025179
revrs satis_02 , replace
gen satis_04 = M045154
revrs satis_04 , replace

gen vote04 = M045049a
replace vote = vote-1
replace vote = . if vote>1

* controls
gen age = M045193

gen pid04 = M045058x
replace pid = pid+1
replace pid = . if pid>7


gen income00 = M023149
replace income00 =. if income00>7

gen income = M045180x
replace income =. if income>7

gen race = M023150
gen white = 1 if race==5

gen female = M001029
recode female (2=1) (1=0)

gen edu = M000913

gen ideology_2000 = M000446
replace ideology_2000 = ideology_2000-1

gen public_affairs_2000 = M001367
revrs public_affairs_2000 , replace

gen natl_econ_2004 =  M045091x
revrs natl_econ_2004 , replace

*********************************************
* Table 3 and predicted values for Figure 5 *
*********************************************
reg satis_04 c.racial_resentment##i.vote ideology public_affairs natl_econ ///
	age income edu female satis_00 if white==1
margins , at(racial_resentment=(1(.25)5)) over(vote) post

***************
* Appendicies *
***************
* Table C.7 and predixted values for Figure C.4
ologit satis_04 c.racial_resentment##i.vote ideology public_affairs natl_econ ///
	age income edu female satis_00 if white==1
margins , at(racial_resentment=(1(.25)5)) over(vote) post
